﻿using System;
using System.Diagnostics.Tracing;
using System.Text.Json;

namespace Jack.EntityFrameworkCore.WebAPITest.EventListeners
{
    public class SqlClientListener : EventListener
    {
        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            //Console.WriteLine(eventSource.Name);
            //EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All);
            //base.OnEventSourceCreated(eventSource);
        }

        protected override void OnEventWritten(EventWrittenEventArgs eventData)
        {
            //Console.WriteLine(JsonSerializer.Serialize(eventData, new JsonSerializerOptions { MaxDepth = 3 }));
            //base.OnEventWritten(eventData);
            //Console.WriteLine(eventData.Payload[0]);
        }
    }
}

// https://docs.microsoft.com/zh-cn/sql/connect/ado-net/enable-eventsource-tracing?view=sql-server-ver16
// https://mysqlconnector.net/overview/logging/
// https://mysqlconnector.net/api/mysqlconnector/mysqlconnectiontype/
